use crate::controllers::{cert_controller, policy_controller, token_controller, user_controller};
use crate::middlewares::filter::key_init_filter::KeyInitFilter;
use actix_web::web;

/// configure routes
pub fn configure_user_routes(cfg: &mut web::ServiceConfig) {
    cfg.service(
        web::scope("/user")
            .route("/all", web::get().to(user_controller::get_all_users))
            .route("/getnonce", web::get().to(user_controller::get_nonce))
            .route("/del/{id}", web::get().to(user_controller::delete_user_by_id)),
    );
    cfg.service(
        web::scope("/token")
            .wrap(KeyInitFilter)
            .route("/verify", web::post().to(token_controller::verify_token)),
    );
    cfg.service(
        web::scope("/policy")
            .route("", web::post().to(policy_controller::add_policy))
            .route("", web::put().to(policy_controller::update_policy))
            .route("", web::delete().to(policy_controller::delete_policy))
            .route("", web::get().to(policy_controller::query_policy)),
    );
    cfg.service(
        web::scope("/cert")
            .route("", web::get().to(cert_controller::get_certs))
            .route("", web::post().to(cert_controller::add_cert))
            .route("", web::put().to(cert_controller::update_cert))
            .route("", web::delete().to(cert_controller::delete_cert)),
    );
}
